﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace text.Tree
{
    
    //Definition for a binary tree node.模板类型
    public class TreeNode
    {
         public int val;
         public TreeNode left;
         public TreeNode right;
         public TreeNode(int x) { val = x; }
     }
    public class TwoTree_104
    {
        public int MaxDepth(TreeNode root)
        {
            if (root == null)
                return 0;
            else
            {
                int leftLength = MaxDepth(root.left);
                int rightLength = MaxDepth(root.right);
                return Math.Max(leftLength, rightLength) + 1;
            }
        }
    }
}
